/**
 * vertexbufferobject.h
 * 
 * @author Zsolt Horváth 
 * @date   3. 4. 2011
 * 
 */

#ifndef BUFFER_OBJECT_H
#define BUFFER_OBJECT_H

#include <GL/glew.h>
#include <GL/glu.h>

/**
 * OpenGL Vertex Array Object
 */
class BufferObject {
    
    public:
        
        /**
         * Constructor
         * 
         * @param GLenum target - target buffer object
         * @param bool bindToDefaultVAO - bind to default VAO
         */
        BufferObject (GLenum target, bool bindToDefaultVAO = true);
        
        /**
         * Destructor
         */
        ~BufferObject ();

        /**
         * Get ID of buffer
         */
        GLuint getID ();
        
        /**
         * Bind vertex array object 
         */
        void bind ();
        
        /**
         * Set buffer data
         * @param GLsizeiptr size - size in bytes of the buffer
         * @param const GLvoid *data - pointer to data
         * @param GLenum usage - expected usage pattern
         */
        void setData (GLsizeiptr size, const GLvoid *data, GLenum usage = GL_STATIC_DRAW);
        
    protected:
        
        /**
         * ID of vertex array object
         */
        GLuint id;
        
        /**
         * 
         */
        GLenum target;
        
        /**
         * Generate new vertex array object
         */
        void generate ();
        
};

#endif /* BUFFER_OBJECT_H */